﻿using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria.UI;

namespace Terraria.GameContent.UI.Elements
{
	// Token: 0x020003EB RID: 1003
	public class UIImageButton : UIElement
	{
		// Token: 0x06002384 RID: 9092 RVA: 0x00478904 File Offset: 0x00476B04
		public UIImageButton(Texture2D texture)
		{
			this._texture = texture;
			this.Width.Set((float)this._texture.Width, 0f);
			this.Height.Set((float)this._texture.Height, 0f);
		}

		// Token: 0x06002385 RID: 9093 RVA: 0x0047896C File Offset: 0x00476B6C
		public void SetImage(Texture2D texture)
		{
			this._texture = texture;
			this.Width.Set((float)this._texture.Width, 0f);
			this.Height.Set((float)this._texture.Height, 0f);
		}

		// Token: 0x06002386 RID: 9094 RVA: 0x004789B8 File Offset: 0x00476BB8
		protected override void DrawSelf(SpriteBatch spriteBatch)
		{
			CalculatedStyle dimensions = base.GetDimensions();
			spriteBatch.Draw(this._texture, dimensions.Position(), Color.White * (base.IsMouseHovering ? this._visibilityActive : this._visibilityInactive));
		}

		// Token: 0x06002387 RID: 9095 RVA: 0x000191FD File Offset: 0x000173FD
		public override void MouseOver(UIMouseEvent evt)
		{
			base.MouseOver(evt);
			Main.PlaySound(12, -1, -1, 1, 1f, 0f);
		}

		// Token: 0x06002388 RID: 9096 RVA: 0x0001921B File Offset: 0x0001741B
		public void SetVisibility(float whenActive, float whenInactive)
		{
			this._visibilityActive = MathHelper.Clamp(whenActive, 0f, 1f);
			this._visibilityInactive = MathHelper.Clamp(whenInactive, 0f, 1f);
		}

		// Token: 0x04003FC7 RID: 16327
		private Texture2D _texture;

		// Token: 0x04003FC8 RID: 16328
		private float _visibilityActive = 1f;

		// Token: 0x04003FC9 RID: 16329
		private float _visibilityInactive = 0.4f;
	}
}
